/*
    klib_proc_threads.h

    contains kernel library functionality for low-level per-process thread handling

    Author: Aidan Goddard 18/8/13
*/

#ifndef KLIB_PROC_THREADS_H_INCLUDED
#define KLIB_PROC_THREADS_H_INCLUDED

#include"ktypes.h"

uint64_t	__KLIB__SpawnNewThread(uint64_t(*start_address)(void*), void *data, void *stack_ptr);
void		__KLIB__KillThisThread(uint64_t return_value);
uint64_t	__KLIB__WaitThisThread(void);
uint64_t	__KLIB__SleepThisThread(uint32_t sleep_time);
uint32_t	__KLIB__WakeThread(uint64_t TID, uint64_t message);
uint32_t	__KLIB__WakeThreadEx(uint64_t TID);
uint32_t	__KLIB__KillThread(uint64_t TID, uint64_t message);
uint64_t	__KLIB__SpawnSystemProcess(uint64_t(*start_address)(void), void *stack_ptr, uint64_t param1, uint64_t param2, char *image_name, uint32_t image_length, char *description, uint32_t description_length);
void 		__KLIB__KillThisProcess(uint64_t exit_value);

#define WAKE_THREAD_SUCCESS 0
#define WAKE_THREAD_NOT_SLEEPING 1
#define WAKE_THREAD_NOT_IN_PROC 2

#define KILL_THREAD_SUCCESS 0
#define KILL_THREAD_NOT_ALIVE 1
#define KILL_THREAD_NOT_IN_PROC 2

#endif
